package com.senior.sendmessage.common;

import lombok.Builder;
import lombok.Data;

/**
 * @author bjl_m
 */
@Data
@Builder
public class ResultResponse<T> {
    private String code;
    private String message;
    private T data;

    public static ResultResponse success() {
        return ResultResponse.builder().code(CommonEnum.SUCCESS.getCode()).message(CommonEnum.SUCCESS.getMessage()).build();
    }

    public static <T> ResultResponse<T> success(T object) {
        return (ResultResponse<T>) ResultResponse.builder().code(CommonEnum.SUCCESS.getCode()).message(CommonEnum.SUCCESS.getMessage()).data((T) object).build();
    }

    public static <T> ResultResponse<T> fail(String string) {
        return (ResultResponse<T>) ResultResponse.builder().code(CommonEnum.FAILED.getCode()).message(string).build();
    }
}
